package com.wanxing.sellerapp.data.db

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.wanxing.sellerapp.data.bean.SyncOrder
import com.wanxing.sellerapp.data.bean.SyncVideo

@Database(entities = [SyncOrder::class,SyncVideo::class], version = 1)
abstract class LocalDB  : RoomDatabase() {

    abstract fun syncOrderDao(): SyncOrderDao
    abstract fun syncVideoDao(): SyncVideoDao

    companion object {
        private var instance: LocalDB? = null
        @Synchronized
        fun get(context: Context): LocalDB {
            if (instance == null) {
                instance = Room.databaseBuilder(
                    context.applicationContext,
                    LocalDB::class.java,
                    "sellerDB"
                ).build()
            }
            return instance!!
        }
    }
}